package com.Lyy.controller;

import com.Lyy.entity.Dept;
import com.Lyy.service.DeptSEI;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Data
@Component
public class DeptCO {
    @Autowired
    private DeptSEI deptSEI;

    public List<Dept> SelectDeptAll() {
        return deptSEI.SelectDeptAll();
    }

    public Dept SelectDeptOne(int id) {
        return deptSEI.SelectDeptOne(id);
    }

    public String AddDept(Dept dept) {
        String Result = deptSEI.AddDept(dept) > 0 ? "成功添加" + deptSEI.AddDept(dept) + "条信息" : "无效操作";
        return Result;
    }

    public String DelDeptByID(int id) {
        String Result = deptSEI.DelDeptByID(id) > 0 ? "成功删除" : "无效操作";
        return Result;
    }

    public String UpdateDeptByID(Dept dept) {
        String Result = deptSEI.UpdateDeptByID(dept) > 0 ? "成功修改" + deptSEI.UpdateDeptByID(dept) + "条信息" : "无效操作";
        return Result;
    }
}
